//
//  YDYMeViewController.m
//  DYSisterAPP
//
//  Created by 杨德勇 on 16/7/26.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYMeViewController.h"
#import "YDYMeViewCell.h"
#import "YDYMeFooterView.h"
#import "YDYSettingViewController.h"
@interface YDYMeViewController ()

@end

@implementation YDYMeViewController

-(instancetype)init{
   return  [self initWithStyle:UITableViewStyleGrouped];
   
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupNavigationBarItems];
    
    
    self.tableView.contentInset = UIEdgeInsetsMake(YDYCellMargin - 35, 0, 0, 0);
    self.tableView.sectionFooterHeight = YDYCellMargin;
    self.tableView.sectionHeaderHeight = 0;
    
    //设置下面大方块 
    self.tableView.tableFooterView = [[YDYMeFooterView alloc]init];
   
}

-(void)setupNavigationBarItems{
    
    self.navigationItem.title = @"我的";

    UIBarButtonItem *barBtn1 = [YDYUIBarButtonItemManager ydy_itemWithImgName:@"mine-moon-icon" selectImgName:@"mine-moon-icon-click" target:self action:@selector(mineMoonIconDidClick)];
    
    UIBarButtonItem *barBtn2 = [YDYUIBarButtonItemManager ydy_itemWithImgName:@"mine-setting-icon" selectImgName:@"mine-setting-icon-click" target:self action:@selector(mineSettingIconDidClick)];

    self.navigationItem.rightBarButtonItems =  @[barBtn2,barBtn1];
   

    
}

-(void)mineMoonIconDidClick{
    YDYLogFunc
    
}
-(void)mineSettingIconDidClick{
    YDYSettingViewController *settingController = [[YDYSettingViewController alloc]init];
    
    [self.navigationController pushViewController:settingController animated:YES];
}


#pragma mark -
#pragma mark -数据源

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellReuseID = @"meCell";
    YDYMeViewCell  *cell = [self.tableView dequeueReusableCellWithIdentifier:cellReuseID];
    if (!cell) {
        cell = [[YDYMeViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%zd",indexPath.section];
    
    
    switch (indexPath.section) {
        case 0:
            cell.textLabel.text = @"注册/登陆";
            cell.imageView.image = [UIImage imageNamed:@"setup-head-default"];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            
            break;
            
        case 1:
            cell.textLabel.text = @"离线下载";
            cell.imageView.image = nil;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            
            break;
            
        default:
            cell.imageView.image = nil;
            cell.accessoryType = UITableViewCellAccessoryNone;
            break;
    }
    
    
    return cell;
}

@end
